package com.mriassl.rabbitmq.direct;

import java.io.IOException;

import com.mriassl.rabbitmq.base.AbstractProducer;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

public class LogProducer extends AbstractProducer {
	
	@Override
	protected void doSometing(Connection conn, Channel channel) throws IOException {
		channel.exchangeDeclare(LogConsts.EXCHANGE_NAME, BuiltinExchangeType.DIRECT);
		int count = 0;
		while(count<20){
			String message = "Hello World! " + count;
			channel.basicPublish(LogConsts.EXCHANGE_NAME, LogConsts.ROUTING_KEYS[count%4], null, message.getBytes());
			System.out.println(" [x] Sent '" + message + "'");
			count++;
		}
	}
	
	public static void main(String[] args) throws Exception {
		LogProducer plog = new LogProducer();
		plog.publicMsg();
	}
	
}
